@model GenDbTableDto
@{
    var className = Model.EntityName;
    var classNameRemark = Model.DisplayName;

    var ignores = new string[]
    {
        "Id",
        "CreationTime",
        "CreatorUserId",
        "LastModificationTime",
        "LastModifierUserId",
        "DeletionTime",
        "DeleterUserId",
        "IsDeleted"
    };

    var tableInfos = Model.TableInfos
        .Where(w => !ignores.Contains(w.ColumnName))
        .OrderBy(w => w.Position)
        .ToList()
        ;
    var searchKeyWords = new[] { "Title", "Name", "Phone", "Address", "Email" };
    var searchKeyWord = string.Empty;
    foreach (var item in searchKeyWords)
    {
        if (tableInfos.Any(w => w.ColumnName == item))
        {
            searchKeyWord = item;
            break;
        }
    }
}
<pre>
namespace @(Model.Namespace).Api.Admin.ApplicationServices.Apps;

/// <summary>
/// @(classNameRemark) 服务 @(className)Service
/// </summary>
public class @(className)Service : ApplicationService<@("IRepository")<@(className)>>
{
    public @(className)Service(IRepository<@(className)> defaultRepository)
        : base(defaultRepository)
    {

    }

    /// <summary>
    /// 获取列表数据
    /// </summary>
    /// <param name="pagingSearchInput"></param>
    /// <returns></returns>
    public async Task<@("PagingView")> FindListAsync(PagingSearchInput<@(className)> pagingSearchInput)
    {
        var query = this._defaultRepository.Select
                @if (!string.IsNullOrWhiteSpace(searchKeyWord))
                {
                    <pre>.WhereIf(!string.IsNullOrWhiteSpace(pagingSearchInput.Search?.@(searchKeyWord)), w => w.@(searchKeyWord).Contains(pagingSearchInput.Search.@(searchKeyWord) ?? ""))</pre>
                }
                .OrderByDescending(w => w.CreationTime)
                .Select(w => new
                {
                    w.Id,
                    @(string.Join(',', tableInfos.Select(w => "w." + w.ColumnName)))@(",")
                    w.LastModificationTime,
                    w.CreationTime
                })
            ;

        var result = await _defaultRepository.AsPagingViewAsync(query, pagingSearchInput);

        // 覆盖值
        result
            .FormatValue(query, w => w.CreationTime, (oldValue) => oldValue.ToString("yyyy-MM-dd"))
            .FormatValue(query, w => w.LastModificationTime, (oldValue) => oldValue?.ToString("yyyy-MM-dd"))
            ;

        // 设置列
        //result.GetColumn(query, w => w.OperatorName).SetColumn("操作人");
        //result.GetColumn(query, w => w.OperatorName!).SetColumn<@("SysUser")>(w => w.Name!);

        return result;
    }

    /// <summary>
    /// 根据id数组删除
    /// </summary>
    /// <param name="ids">ids</param>
    /// <returns></returns>
    public async Task DeleteListAsync(List<@("Guid")> ids)
    {
        await this._defaultRepository.DeleteByIdsAsync(ids);
    }

    /// <summary>
    /// 查询表单数据
    /// </summary>
    /// <param name="id">id</param>
    /// <returns></returns>
    public async Task<@("Dictionary")<@("string,object")>> FindFormAsync(Guid id)
    {
        var res = new Dictionary<@("string, object")>();
        var form = await this._defaultRepository.FindByIdAsync(id);
        form = form.NullSafe();

        res[nameof(id)] = id == Guid.Empty ? "" : id;
        res[nameof(form)] = form;
        return res;
    }

    /// <summary>
    /// 保存数据
    /// </summary>
    /// <param name="form">form</param>
    /// <returns></returns>
    public Task SaveFormAsync(@className form)
    {
        return this._defaultRepository.InsertOrUpdateAsync(form);
    }

    /// <summary>
    /// 导出Excel
    /// </summary>
    /// <param name="pagingSearchInput"></param>
    /// <returns></returns>
    public async Task<@("byte[]")> ExportExcelAsync(PagingSearchInput<@(className)> pagingSearchInput)
    {
        pagingSearchInput.Page = -1;
        var tableViewModel = await this.FindListAsync(pagingSearchInput);
        return ExcelUtil.ExportExcelByPagingView(tableViewModel, null, "Id");
    }



}

</pre>